package com.qianbei.common.base;

import android.app.Activity;
import android.app.DialogFragment;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.qianbei.share.ui.NewShareFragmentDialog;

/**
 * Created by gml on 16/9/19.
 */
public class BaseFragmentDialog extends DialogFragment implements View.OnClickListener {

    protected Activity mContext;
    private BaseFragmentClick fragmentClick;


    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        mContext = activity;
        try {
            fragmentClick = (BaseFragmentClick) activity;
        } catch (ClassCastException e) {
            throw new ClassCastException(activity.toString()
                    + "must implement OnArticleSelectedListener");
        }
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setStyle(DialogFragment.STYLE_NORMAL, android.R.style.Theme_Black);
//				Theme_Black_NoTitleBar_Fullscreen);
    }


    public void onClick(View v) {
        dismiss();
        if (fragmentClick != null) {
            fragmentClick.fClick(v.getId());
        }
    }


    /**
     * 简化Activity启动方法
     *
     * @param targetClass
     */
    public void startActivity(Class<? extends BaseActivity> targetClass) {
        startActivity(new Intent(getActivity(), targetClass));
    }

}
